﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using Monocle.DataModel;

namespace Monocle.Models
{
    public class AppViewModel
    {
        private tApp _dto;
        public AppViewModel(tApp dto)
        {
            _dto = dto;
        }

        public AppViewModel()
        {
            _dto = new tApp();
        }

        public PageCollectionViewModel PageList { get; set; }


        [HiddenInput(DisplayValue = false)]
        public Guid ID
        {
            get { return _dto.PK_tApp; }
            set { _dto.PK_tApp = value; }
        }

        [ScriptIgnore]
        [HiddenInput(DisplayValue = false)]
        public byte[] Version
        {
            get { return _dto.Version; }
            set { _dto.Version = value; }

        }

        [Required(ErrorMessageResourceName = "AppViewModel_Name_Required", ErrorMessageResourceType = typeof(Resources.Monocle))]
        [Display(Name = "AppViewModel_Name", ResourceType = typeof(Resources.Monocle))]
        public String Name
        {
            get { return _dto.Name; }
            set { _dto.Name = value; }
        }

        [HiddenInput(DisplayValue = false)]
        public String PageOrder { get; set; }

        public void UpdateFromDTO(tApp dto)
        {
            _dto = dto;
        }
    }
}